// If your port is set to 80,
// use administrator privileges to execute the command line.
// For example, Mac: sudo npm run
const path = require('path');

function resolve(dir) {
    // 此处使用path.resolve 或path.join 可自行调整
    // path.resolve(__dirname, 'examples'),
    return path.join(__dirname, dir);

}

const port = 1024; // dev port
const webpack = require('webpack');

process.env.NODE_ENV = 'development';
module.exports = {
    assetsDir: 'static',
    publicPath: '/',
    outputDir: './target/dist',
    lintOnSave: false,
    // lintOnSave: process.env.NODE_ENV === 'development',
    productionSourceMap: false,
    transpileDependencies: [/node_modules[/\\\\](element-ui|vuex|vue-router-tab|jsoneditor|vanilla-picker)[/\\\\]/],
    devServer: {
        disableHostCheck: true,
        host: '0.0.0.0',
        port,
        open: true,
        overlay: {
            warnings: false,
            errors: true
        },
        proxy: {
            '/api/': {
                target: process.env.VUE_APP_SERVER_URL,
                ws: true,
                changeOrigin: true,
                pathRewrite: {
                    '^/api/': '/'
                }
            }
        }
    },
    chainWebpack: config => {
        config.resolve.alias
            .set('@', resolve('src'))
            .set('views', resolve('src/views'))
            .set('assets', resolve('src/assets'))
            .set('components', resolve('src/components'))
            .set('base', resolve('baseConfig'))
            .set('public', resolve('public'));
        // config.entry.app = ['@babel/polyfill', './src/main.js'];
        // config.entry('main').add('babel-polyfill');
        // config.module
        // 	.rule('static')
        // 	.test(/\.js$/)
        // 	.use('babel-loader')
        // 	.loader('babel-loader')
        // 	.end();
    },
    configureWebpack: config => {

    },
    css: {
        loaderOptions: {
            // 给 sass-loader 传递选项
            scss: {
                // @/ 是 src/ 的别名
                // 注意：在 sass-loader v7 中，这个选项名是 "data"
                prependData: ` 
           
            `
            },
            less: {
                // 若 less-loader 版本小于 6.0，请移除 lessOptions 这一级，直接配置选项。
                lessOptions: {
                    modifyVars: {
                        // 直接覆盖变量
                        'text-color': '#111',
                        'border-color': '#eee',
                        'cell-line-height': '88px',
                        // 或者可以通过 less 文件覆盖（文件路径为绝对路径）
                        hack: 'true; '
                    }
                }
            }
        }
    }
};